#include "StateManagement.h"
#include "InGameState.h"
StateManagement* StateManagement::s_pStateManager = 0;

StateManagement::StateManagement(void)
{
	Init();	
}

StateManagement::~StateManagement(void)
{
	Release();
	delete s_pStateManager;
}

void StateManagement::Init()
{
	m_apStates.push(new CMainMenuState());
}

void StateManagement::Update(float dt)
{
	m_apStates.top()->Update(dt);
}

void StateManagement::Render()
{
	m_apStates.top()->Render();
}

void StateManagement::Release()
{
	while(!m_apStates.empty()) 
	{
		delete m_apStates.top();
		m_apStates.pop();
	}
}

void StateManagement::SwitchState(IState* state)
{
	Release();
	PushState(state);
}

void StateManagement::PushState(IState* state)
{
	m_apStates.push(state);
}

void StateManagement::PopState()
{
	delete m_apStates.top();
	m_apStates.pop();
}